﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "ActionBarDialog.h"
#include "GcmpGuiQt.h"
#include "WeakPtr.h"



/// \brief ActionBarDialogReference 用以构造ActionBarDialog和间接管理dialog的生命周期
class  GCMP_GUI_QT_EXPORT ActionBarDialogReference : public gcmp::IActionInputDialog
{       
public:
    ActionBarDialogReference(QWidget* pViewParent=nullptr);
    virtual ~ActionBarDialogReference();

    virtual gcmp::IActionInputEvent* GetInputEvent() override;

    void ResetPosition();  //重置Dialog的位置

    /// \brief 初始化参数对话框，根据传入的参数创建对话框上的各种控件
    ///
    /// \param  title dialog 标题 dlgCtrlDefines 控件定义数组  pAction 传入的Action
    void InitDlg(const std::wstring& title, std::vector<gcmp::OwnerPtr<gcmp::IControlDefinition>>&& dlgCtrlDefines, gcmp::IAction* pAction);

    /// \brief 设置参数对话框标题
    ///
    /// \param strTitle 标题文本
    void SetWindowTitle(const std::wstring& strTitle);

    gcmp::IAction* GetAction();  //获得IAction指针

    void Show() const;  //调用了QWidget中的show()方法

private:
    gcmp::WeakPtr<ActionBarDialog> m_wpDialog;   
    QWidget *m_pParentWidget;   //记下传入的父控件
   
};